package com.feihong.txgw.tx_precenter;

import com.feihong.txgw.inter.contract.location.ILocationContract;
import com.feihong.txgw.model.bean.user.SortModel;
import com.feihong.txgw.tx_model.LocationMainMode;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName LocationMainPrecenter
 * @package com.feihong.txgw.tx_precenter
 * @data 2018/5/7 18:15
 * @Describe
 * @Change
 */
public class LocationMainPrecenter extends ILocationContract.AbLocationMainPrecenter{

    public static LocationMainPrecenter create(){
        return new LocationMainPrecenter();
    }

    @Override
    public void countCityHits(String regionID) {
        mIModel.countCityHits(regionID).subscribe(new Observer() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Object o) {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void loadAllCity() {
        mIModel.getAllCity().subscribe(new Observer<SortModel>() {
            @Override
            public void onSubscribe(Disposable d) {
                mRxManager.register(d);
            }

            @Override
            public void onNext(SortModel s) {
                mIView.loadAllCityResult(s);
            }

            @Override
            public void onError(Throwable e) {
                mIView.loadDataError();
            }

            @Override
            public void onComplete() {
                mIView.loadDataComplated();
            }
        });
    }

    @Override
    public ILocationContract.ILocationMainModel getModel() {
        return LocationMainMode.create();
    }

    @Override
    public void onStart() {

    }
}
